package com.schoolCommunity.controller;


import com.schoolCommunity.entity.ConfessionWallMessage;
import com.schoolCommunity.entity.Information;
import com.schoolCommunity.service.ConfessionWallMessageService;
import com.schoolCommunity.service.ConfessionWallService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author YTH
 * @since 2020-09-09
 */
@CrossOrigin
@RestController
public class ConfessionWallMessageController {

    @Autowired
    private ConfessionWallMessageService ConfessionWallMessageService;

    //添加一条留言
    @PostMapping("/InsertConfessionWallMessage")
    public Information InsertConfessionWallMessage(@RequestBody ConfessionWallMessage ConfessionWallMessage) {
        return ConfessionWallMessageService.InsertConfessionWallMessage(ConfessionWallMessage);
    }

    //按照表白墙ID获取下面的留言
    @GetMapping("/GetConfessionWallMessage/{ConfessionWallId}")
    public Information GetConfessionWallMessage(@PathVariable("ConfessionWallId") long ConfessionWallId) {
        return ConfessionWallMessageService.GetConfessionWallMessage(ConfessionWallId);
    }

    //删除一条留言
    @PostMapping("/DeleteConfessionWallMessage")
    public Information DeleteConfessionWallMessage(@RequestBody long id) {
        return ConfessionWallMessageService.DeleteConfessionWallMessage(id);
    }

    //获取指定用户的留言
    @PostMapping("/GetConfessionWallMessageByMemberId/{memberId}")
    public Information GetConfessionWallMessageByMemberId(@PathVariable("memberId") long memberId) {
        return ConfessionWallMessageService.GetConfessionWallMessageByMemberId(memberId);
    }

    //管理员获取尚未审批的留言
    @PostMapping("/GetNotSuggestConfessionWallMessage")
    public Information GetNotSuggestConfessionWallMessage() {
        return ConfessionWallMessageService.GetNotSuggestConfessionWallMessage();
    }

    //管理员审核表白墙留言
    @GetMapping("/AdminSuggestConfessionWallMessage/{confessionWallMessageId}/{suggestResult}")
    public Information AdminSuggestConfessionWallMessage(@PathVariable("confessionWallMessageId") long confessionWallMessageId, @PathVariable("suggestResult") int suggestResult) {
        return ConfessionWallMessageService.AdminSuggestConfessionWallMessage(confessionWallMessageId, suggestResult);
    }


}

